import axios from 'axios';

const httpUrl = 'http://localhost:8090';

const service = axios.create({
    baseURL: httpUrl,
    timeout: 10000,
    headers: {
        'Content-Type': 'application/json',
    },
});

// 请求拦截器
service.interceptors.request.use(
    config => {
        // 可在此处添加token等操作
        return config;
    },
    error => {
        return Promise.reject(error);
    }
);

// 响应拦截器
service.interceptors.response.use(
    response => {
        return response.data;
    },
    error => {
        return Promise.reject(error);
    }
);

export default service;
